package br.com.monografia;



import br.com.android.list.CriaTelaAlimentos;
import br.com.monografia.util.ConnectDatabase;
import android.os.Bundle;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;


public class DiabetesActivity extends Activity {
	
	private ConnectDatabase conexao = null;
	Context context;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_diabetes);
		Button bteste = (Button) findViewById(R.id.bteste);
		Button binsere = (Button) findViewById(R.id.binsere);
		Button brecupera = (Button) findViewById(R.id.brecupera);
		Button blistar = (Button) findViewById(R.id.blistar);
		
		
		blistar.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				Intent tela = new Intent();
				tela.setClass(DiabetesActivity.this, CriaTelaAlimentos.class);
				startActivity(tela);				
			}
		});
				
		
		bteste.setOnClickListener(new View.OnClickListener() {			
			@Override
			public void onClick(View v) {				
				try {
					conexao = new ConnectDatabase(getApplicationContext());
					conexao.getDatabase();	
					conexao.close();
					context = getApplicationContext();
					AlertDialog.Builder msg = new AlertDialog.Builder(DiabetesActivity.this);
					msg.setTitle("Sucesso");
					msg.setMessage("Banco criado com sucesso");
					msg.setNeutralButton("Ok", null);
					msg.show();
				} catch (Exception e) {
					Toast toast = Toast.makeText(DiabetesActivity.this, "Erro!"+e.getMessage().toString()+"", Toast.LENGTH_SHORT);
				    toast.show();
				}
							
			}
		});
		
		binsere.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent tela = new Intent();
				tela.setClass(DiabetesActivity.this, PerfilActivity.class);
				startActivity(tela);
			}
		});
		
		brecupera.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent tela = new Intent();
				tela.setClass(DiabetesActivity.this, BuscarPerfilActivity.class);
				startActivity(tela);
			}
		});
	};

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
	
		return true;
	}
	

}
